<?php
/**
 * Created by PhpStorm.
 * User: yiyu
 * Email: smalleasyu@gmail.com
 * Date: 2020-02-15 23:20:08
 * Desc:
 */

namespace app\api\controller;

use app\api\service\MarqueeService;
use app\base\model\user\User;
use app\base\model\goods\{GoodsGroupInfo, GoodsBaseInfo};
use app\core\cache\{RedisCache, RedisKeys};
use app\core\log\Log4dd;
use QL\QueryList;
use think\Db;

class TestController
{
    public function test()
    {
        $baseUrl = 'https://www.xiurenji.com';

        $data = QueryList::get($baseUrl)->find('.lm table a')->attrs('href');

        $items = $data->all();

        array_shift($items);

        var_dump($items);

        exit;

        foreach ($items as $item) {
            $url = $baseUrl . $item;

            echo $url. '<br/>';

            $data = QueryList::get($url)->find('.nr3 .w985 table .dan a')->attrs('href');

            $sons = $data->all();

            foreach ($sons as $son) {
                echo $baseUrl . $son . '<br/>';
            }
        }


    }

    public function AmendPeopleGetWishCoin()
    {
        $goods = GoodsBaseInfo::alias('gb')
        ->join('xy_goods.xy_goods_platform_info gp', 'gb.goods_id=gp.goods_id', 'INNER')
        ->field('gb.goods_id,gb.need_people,gb.people_get_wish_coin,gp.platform_price')
        ->select() ;

        if ($goods) {
            foreach ($goods as $good) {
                $people_get_wish_coin = \app\admin\service\GoodsService::getPeopleGetWishCoin($good['platform_price'], $good['need_people']);
                //GoodsBaseInfo::where('goods_id', $good['goods_id'])->update(['people_get_wish_coin' => $people_get_wish_coin]);
                Log4dd::info('修改商品信息', ['goods_id' => $good['goods_id'], 'old_coin' => $good['people_get_wish_coin'], 'new_coin' => $people_get_wish_coin, 'price' => $good['platform_price'], 'need_people' => $good['need_people']]);
                GoodsBaseInfo::delGoodsInfoCache($good['goods_id']);
            }
        }

    }

}